//
//  MPlusMyClassVideoListViewController.m
//  medicineplus
//
//  Created by gufei on 15-5-20.
//  Copyright (c) 2015年 chn_ruby@126.cn. All rights reserved.
//

#import "MPlusMyClassVideoListViewController.h"
#import "MPlusVideoTableViewCell.h"
#import "MPlusDefine.h"

@interface MPlusMyClassVideoListViewController ()<UITableViewDataSource,UITableViewDelegate>  {
}
@property (nonatomic, strong) NSMutableArray *aNewsListArray;
@property (nonatomic, retain) UITableView *aTableView;

@end

@implementation MPlusMyClassVideoListViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    _aNewsListArray = [@[@"photo_sample_01",
                         @"photo_sample_02",
                         @"photo_sample_03",
                         @"photo_sample_04",
                         @"photo_sample_05",
                         @"photo_sample_06",
                         @"photo_sample_07",
                         @"photo_sample_08",] mutableCopy];
    UITableView *tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT-153) style:UITableViewStylePlain];
    // 设置tableView的数据源
    tableView.dataSource = self;
    // 设置tableView的委托
    tableView.delegate = self;
    self.aTableView = tableView;
    [self.view addSubview:self.aTableView];
    // 去除多余的分割线
    [self setExtraCellLineHidden:_aTableView];
}

#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    // Return the number of sections.
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    // Return the number of rows in the section.
    return _aNewsListArray.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    NSUInteger row = [indexPath row];
    NSString *cellIdentifier = [NSString stringWithFormat:@"%lu", (unsigned long)row];
    MPlusVideoTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
    if (cell == nil) {
        cell = [[MPlusVideoTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
                                             reuseIdentifier:cellIdentifier];
    }
    cell.aTitle1.text = @"眼科学";
    cell.aTitle2.text = @"临床学";
    [cell.aLearnStatus1 setTitle:@"未学习" forState:UIControlStateNormal];
    [cell.aLearnStatus2 setTitle:@"已学习10分钟" forState:UIControlStateNormal];
    [cell.aVideo1 setBackgroundImage:[UIImage imageNamed:_aNewsListArray[row]] forState:UIControlStateNormal];
    [cell.aVideo2 setBackgroundImage:[UIImage imageNamed:_aNewsListArray[row]] forState:UIControlStateNormal];
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    //    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    //    DetailViewController *detailVC = [[DetailViewController alloc]initWithNibName:@"DetailViewController" bundle:nil];
    //    [self.navigationController pushViewController:detailVC animated:YES];
    //消除cell选择痕迹
    [self performSelector:@selector(deselect) withObject:nil afterDelay:0.5f];
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 172;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark -
#pragma mark Table View setExtraCellLineHidden Methods
- (void)setExtraCellLineHidden: (UITableView *)tableView {
    UIView *view =[ [UIView alloc]init];
    view.backgroundColor = [UIColor clearColor];
    [tableView setTableFooterView:view];
    [tableView setTableHeaderView:view];
}

#pragma mark -
#pragma mark Table View Cell deselect Methods
- (void) deselect {
    [_aTableView deselectRowAtIndexPath:[_aTableView indexPathForSelectedRow] animated:YES];
}

/*
 #pragma mark - Navigation
 
 // In a storyboard-based application, you will often want to do a little preparation before navigation
 - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
 // Get the new view controller using [segue destinationViewController].
 // Pass the selected object to the new view controller.
 }
 */

@end
